<template>
  <el-config-provider :locale="locale" :size="size" :z-index="zIndex">
    <slot />
  </el-config-provider>
</template>

<script setup lang="ts">
import { onMounted, nextTick } from 'vue'
import { ElConfigProvider } from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import { fixElementPlusGetBoundingClientRect, listenElementPlusErrors } from '@/utils/elementPlusConfig'

// 配置参数
const locale = zhCn
const size = 'default'
const zIndex = 3000

// 组件挂载时应用修复
onMounted(async () => {
  await nextTick()
  
  console.log('ElementPlusConfigProvider: 应用Element Plus修复...')
  
  // 应用getBoundingClientRect修复
  fixElementPlusGetBoundingClientRect()
  
  // 监听Element Plus错误
  listenElementPlusErrors()
  
  // 延迟再次应用修复，确保所有组件都已加载
  setTimeout(() => {
    console.log('ElementPlusConfigProvider: 延迟应用Element Plus修复...')
    fixElementPlusGetBoundingClientRect()
  }, 200)
})
</script> 